
package org.soekrat.gui.swing.network;

//
// 110121 - AH - Created.
// 110819 - AH - (Bordeaux 1 *) Deprecated.
//

import java.awt.FlowLayout;

import javax.swing.ButtonGroup;
import javax.swing.JPanel;
import javax.swing.JRadioButton;

import org.soekrat.engine.network.NetworkNode;

@Deprecated
@SuppressWarnings("serial")
public final class NetworkLinkEditorPanel extends JPanel 
{
  private NetworkNode m_left=null;
  
  private NetworkNode m_right=null;
  
  private final JRadioButton m_lr=new JRadioButton();
  
  private final JRadioButton m_rl=new JRadioButton();
  
  private final JRadioButton m_uni=new JRadioButton();
  
  /**
   * <p>
   *   Constructor.
   * </p>
   */
  public NetworkLinkEditorPanel()
  {
    setLayout(new FlowLayout(FlowLayout.CENTER));
    
    m_lr.setText("LR");
    m_rl.setText("RL");
    m_uni.setText("Uni");
    
    ButtonGroup bg=new ButtonGroup();
    bg.add(m_lr);
    bg.add(m_rl);
    bg.add(m_uni);
    
    add(m_lr);
    add(m_rl);
    add(m_uni);
    
    clear();
  }
  
  /**
   * <p>
   *   Clears editor.
   * </p>
   */
  public void clear()
  {
    m_left=m_right=null;
    m_lr.setSelected(false);
    m_lr.setEnabled(false);
    m_rl.setSelected(false);
    m_rl.setEnabled(false);
    m_uni.setSelected(false);
    m_uni.setEnabled(false);
  }
  
  /**
   * <p>
   *   Sets nodes to edit link between.
   * </p>
   * @param l Left node.
   * @param r Right node.
   */
  public void setNodes(NetworkNode l, NetworkNode r)
  {
    if (l==null)
    {
      throw new NullPointerException("l");
    }
    if (r==null)
    {
      throw new NullPointerException("r");
    }
    if (l==r)
    {
      throw new IllegalArgumentException("l==r");
    }
    
    
    m_left=l;
    m_right=r;
    
    m_lr.setText(m_left.getName()+" -> "+m_right.getName());
    m_lr.setText(m_left.getName()+" <- "+m_right.getName());
    m_uni.setText(m_left.getName()+" <-> "+m_right.getName());
    
  }
  
}
